package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.ClientAnalysisParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.IClientAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户端分析 Controller
 *
 * @Author LinShiHe
 * @Date 2023/5/25
 */
@Api(value = "客户端分析接口", tags = "客户端分析接口")
@RestController
@RequestMapping("/client/analysis")
public class ClientAnalysisController {

    @Autowired
    private IClientAnalysisService clientAnalysisService;

    /**
     * 获取各操作系统对应的访问量 和 处理时长
     *
     * @param params 参数
     * @return 通用返回对象
     */
    @PostMapping("/getOperatingSystemData")
	@ApiOperation(value = "获取各操作系统对应的访问量 和 处理时长", notes = "获取各操作系统对应的访问量 和 处理时长")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "businessCode", 		value = "业务编码", 			paramType = "query", 	required = true,  	dataType = "String"),
			@ApiImplicitParam(name = "operatingSystem", 	value = "操作系统名称", 		paramType = "query", 	required = false,  	dataType = "String"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", 	required = true,    dataType = "String"),
			@ApiImplicitParam(name = "endTime", 			value = "结束时间", 			paramType = "query", 	required = true,    dataType = "String")
	})
    public R<Object> getOperatingSystemData(@RequestBody ClientAnalysisParams params) {

        return R.ok(clientAnalysisService.getOperatingSystemData(params));
    }


	/**
	 * 获取各浏览器维度的访问量 和 处理时长
	 *
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@PostMapping("/getBrowserData")
	@ApiOperation(value = "获取各浏览器维度的访问量 和 处理时长", notes = "获取各浏览器维度的访问量 和 处理时长")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "systemId",  			value = "系统id",  			paramType = "query", 	required = true, 	dataType = "Integer"),
			@ApiImplicitParam(name = "businessCode", 		value = "业务编码", 			paramType = "query", 	required = true,  	dataType = "String"),
			@ApiImplicitParam(name = "browser", 			value = "浏览器名称", 		paramType = "query", 	required = false,  	dataType = "String"),
			@ApiImplicitParam(name = "startTime", 			value = "开始时间", 			paramType = "query", 	required = true,    dataType = "String"),
			@ApiImplicitParam(name = "endTime", 			value = "结束时间", 			paramType = "query", 	required = true,    dataType = "String")
	})
	public R<Object> getBrowserData(@RequestBody ClientAnalysisParams params) {

		return R.ok(clientAnalysisService.getBrowserData(params));
	}
}
